# 目标 target
target_url = 'http://www.baidu.com'

import urllib.request
# 模拟 浏览器 向服务器发送请求
response = urllib.request.urlopen(target_url)

print("查看response的类型%s" % type(response))
# 查看response的类型<class 'http.client.HTTPResponse'>

# 响应头 Response header
# rh = response.getheaders()
# print(rh)
# ('Bdpagetype', '1'), ('Bdqid', '0xa88760f700074eee')


# 获取URL
# resp_url = response.geturl()
# print(resp_url)


# 状态码 status code
# response.getcode()
# 200 正常


# 按多行读
# content = response.readlines()
# print(content)
# b'<!DOCTYPE html><!--STATUS OK--><html><head><meta

# 按行读  一行
# response.readline()

# 按字节读
# response.read()



